#include "qbtnlineedit.h"

#include "qtexteditdialog.h"

#include <QPainter>
#include <QStyleOptionFrameV2>
#include <QPalette>

QBtnLineEdit::QBtnLineEdit(QWidget *parent) :
    QLineEdit(parent),
    m_button(new QPushButton(this))
{
    m_button->setText("...");
    m_button->setFixedSize(19,19);
    m_button->move(this->width()-21,1);
    m_button->setCursor(QCursor(Qt::ArrowCursor));
    m_button->setFocusProxy(this);
    connect(m_button,SIGNAL(clicked()),this,SLOT(btnClicked()));
    setTextMargins(0,0,21,0);
}

void QBtnLineEdit::resizeEvent(QResizeEvent *)
{
    m_button->move(this->width()-21,1);
}

void QBtnLineEdit::btnClicked()
{
    QTextEditDialog dlg(this->text(),this);

    dlg.exec();
    if(dlg.getRet()==1)
    {
        this->setText(dlg.getText());
    }
}
